//
//  LGConserveTableViewCell.m
//  LuxuryGoods
//
//  Created by 纳里健康 on 2018/6/7.
//  Copyright © 2018年 Future. All rights reserved.
//

#import "LGConserveTableViewCell.h"
#import "Masonry.h"
#import "BrandCollectionViewCell.h"

@implementation LGConserveTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self == [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self setDefaultUI];
    }
    return self;
}

- (void)setDefaultUI
{
    self.topImageView = [[UIImageView alloc] init];
    self.topImageView.image = [UIImage imageNamed:@"2"];
    [self.contentView addSubview:self.topImageView];
    [self.topImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.offset(0);
        make.height.mas_equalTo(150);
    }];
    
    UIView *itemView = [[UIView alloc] init];
    itemView.backgroundColor = WHITE_COLOR;
    [self.contentView addSubview:itemView];
    [itemView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.topImageView.mas_bottom);
        make.left.right.offset(0);
        make.height.mas_equalTo(140);
    }];
    
    
    CGFloat itemWidth = ceilf(SCREEN_WIDTH - 5 * 5)/4;
    
    CGFloat itemHeight = itemWidth + 10;
    
    for (int i = 0 ; i < 4; i ++) {
        BrandCollectionViewCell *btnView = [[NSBundle mainBundle] loadNibNamed:@"BrandCollectionViewCell" owner:self options:nil][0];
        
        CGFloat itemX = i * itemWidth + (i + 1) * 5;
        
        btnView.frame = CGRectMake(itemX, (140 - itemHeight)/2, itemWidth, itemHeight);
        
        btnView.brandImageView.image = [UIImage imageNamed:@"jisumai_baoba"];
        
        btnView.brandName.text = [NSString stringWithFormat:@"我是—— %d",i];
        
        [itemView addSubview:btnView];
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
